class PaymethodsController < ApplicationController
	
	
  # GET /paymethods
  # GET /paymethods.xml
  def index
    @paymethods = Paymethod.all
    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @paymethods }
    end
  end

  # GET /paymethods/1
  # GET /paymethods/1.xml
  def show
    @paymethod = Paymethod.find(params[:id])
    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @paymethod }
    end
  end

  # GET /paymethods/new
  # GET /paymethods/new.xml
  def new
    @paymethod = Paymethod.new
    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @paymethod }
    end
  end

  # GET /paymethods/1/edit
  def edit
    @paymethod = Paymethod.find(params[:id])
  end

  # POST /paymethods
  # POST /paymethods.xml
  def create
    @paymethod = Paymethod.new(params[:paymethod])
    respond_to do |format|
      if @paymethod.save
        flash[:notice] = 'Metodo de Pago creado satisfactoriamente.'
        format.html { redirect_to(@paymethod) }
        format.xml  { render :xml => @paymethod, :status => :created, :location => @paymethod }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @paymethod.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /paymethods/1
  # PUT /paymethods/1.xml
  def update
    @paymethod = Paymethod.find(params[:id])
    respond_to do |format|
      if @paymethod.update_attributes(params[:paymethod])
        flash[:notice] = 'Metodo de Pago creado satisfactoriamente.'
        format.html { redirect_to(@paymethod) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @paymethod.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /paymethods/1
  # DELETE /paymethods/1.xml
  def destroy
    @paymethod = Paymethod.find(params[:id])
    @paymethod.destroy
    respond_to do |format|
      format.html { redirect_to(paymethods_url) }
      format.xml  { head :ok }
    end
  end
  
  # Redirecciona a direccion de entrega de metodo de pago
  def action
	  if params[:is_delivery_address] == "1"
		render :partial => 'nothing'  
	  else 
		render :partial => 'address_partial'  
	  end
  end
  end
